﻿<%@ Page Language="c#" CodeBehind="SearchData.aspx.cs" AutoEventWireup="false" Inherits="UDS.SubModule.WorkAttendance.SearchDataPage" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head runat="server">
  <title>SearchData</title>
  <uds:Style runat="server" Href="~/css/BasicLayout.css" />
</head>
<body>
  <script language="javascript">
  //<!--
  function to_2_digits(v)
  {
    return (v<10) ? "0" + v : v.toString();
  }
  function formatDate(d)
  {
    return d.getFullYear() + "-" + to_2_digits(d.getMonth() + 1) + "-" + to_2_digits(d.getDate());
  }
  
  function quickSelectDate(type)
  {
	  var beginTime;
	  var endTime;
	  var oneMinute = 60 * 1000;
	  var oneHour = 60 * oneMinute;
	  var oneDay = 24 * oneHour;
	  var oneWeek = 7 * oneDay;
  	
	  var todayDate = new Date();	  
	  if(type == "day")
	  {
		  beginTime = formatDate(todayDate);
		  endTime = beginTime;
	  }
	  else if(type=="week")
	  {
	    var daytoMon = todayDate.getDay() - 1;
		  if(todayDate.getDay() == 0) 
			  daytoMon = 6;
  		
		  todayDate.setTime(todayDate.getTime() - daytoMon * oneDay);  		
		  beginTime = formatDate(todayDate);
  		
		  todayDate.setTime(todayDate.getTime() + 6 * oneDay);  		
		  endTime = formatDate(todayDate);
	  }
	  else if(type=="month")
	  {
		  var dateTo1 = todayDate.getDate() - 1;
  		
		  todayDate.setTime(todayDate.getTime() - dateTo1 * oneDay);
  		beginTime = formatDate(todayDate);

		  todayDate.setMonth(todayDate.getMonth() + 1);
		  todayDate.setTime(todayDate.getTime() - oneDay);
		  endTime = formatDate(todayDate);
	  }

    document.getElementById("<%= txtbegintime.ClientID %>").value = beginTime;
	  document.getElementById("<%= txtendtime.ClientID %>").value = endTime;
  }
  
  function show_WA_detail(staff_id, type)
  {
    var url = "StaffData.aspx?staffid=" + staff_id;
    url += "&begintime=" + document.getElementById("<%= txtbegintime.ClientID %>").value;
    url += "&endtime=" + document.getElementById("<%= txtendtime.ClientID %>").value;
    url += "&type=" + type;
    window.open(url, "", "toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
  }
  //-->
  </script>
  <form id="SearchData" method="post" runat="server">
    <ajax:ToolkitScriptManager runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true" />
    <uds:PageTitle runat="server" HintImage="~/DataImages/kaoqin2.gif" Title="考勤查询" />
    <table class="GBText" style="border-collapse: collapse;" bordercolor="#93bee2" cellspacing="0" cellpadding="4" width="100%" border="1">
      <tr>
        <td style="width: 84px">输入时间段</td>
        <td>开始时间：
          <uds:DateTextBox ID="txtbegintime" runat="server" CssClass="inputcss" Columns="10" ReadOnly="True" /><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="None" ControlToValidate="txtbegintime" ErrorMessage="开始时间不能为空" />--结束时间
          <uds:DateTextBox ID="txtendtime" runat="server" CssClass="inputcss" Columns="10" ReadOnly="True" /><asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="None" ControlToValidate="txtendtime" ErrorMessage="结束不能为空" />&nbsp;
          <asp:CompareValidator ID="cvdate" runat="server" Display="None" ControlToValidate="txtendtime" ErrorMessage="结束时间应该大于开始时间" Operator="GreaterThanEqual" ControlToCompare="txtbegintime"></asp:CompareValidator>&nbsp; <asp:RadioButton ID="rbtnthisweek" onclick="quickSelectDate('week');" runat="server" Text="本周" GroupName="quickdate"></asp:RadioButton><asp:RadioButton ID="rbtnthismonth" onclick="quickSelectDate('month');" runat="server" Text="本月" GroupName="quickdate"></asp:RadioButton></td>
      </tr>
      <tr>
        <td style="width: 84px">查找范围</td>
        <td>
          <asp:DropDownList ID="ddlsearchbound" runat="server" Width="300px" AutoPostBack="True">
            <asp:ListItem Value="0" Selected="True">公司</asp:ListItem>
            <asp:ListItem Value="1">职位</asp:ListItem>
            <asp:ListItem Value="2">个人</asp:ListItem>
          </asp:DropDownList>
        </td>
      </tr>
      <tr>
        <td style="width: 84px">请选择</td>
        <td>
          <asp:ListBox ID="lbstaffs" runat="server" CssClass="inputcss" Width="150px" SelectionMode="Multiple" Height="141px" Visible="False"></asp:ListBox>
          <asp:DropDownList ID="ddldepartments" runat="server" Width="150px" Visible="False" />
        </td>
      </tr>
      <tr>
        <td style="width: 84px"></td>
        <td><asp:ValidationSummary runat="server" DisplayMode="BulletList" ShowMessageBox="true" ShowSummary="false" /></td>
      </tr>
      <tr>
        <td align="center" colspan="2" height="30">
          <asp:Button ID="btnsearch" runat="server" CssClass="buttoncss" Text=" 查  询 " />
        </td>
      </tr>
      <tr>
        <td align="right" colspan="2">
          <asp:DataGrid ID="AttendanceGrid" runat="server" Width="100%" CellPadding="3" BorderWidth="1px" BorderColor="#93BEE2" DataKeyField="staff_id" EnableViewState="False" AutoGenerateColumns="False">
            <HeaderStyle Font-Size="X-Small" BackColor="#E8F4FF"></HeaderStyle>
            <Columns>
              <asp:BoundColumn DataField="realname" HeaderText="姓名" />
              <asp:TemplateColumn HeaderText="正常天数">
                <ItemTemplate>
                  <a href="javascript:void(0);" onclick="show_WA_detail(<%#(int)(((DataRowView)Container.DataItem)["Staff_ID"])%>,1)"><%# GetGridData((int)(((DataRowView)Container.DataItem)["Staff_ID"]),0)%></a>
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn HeaderText="迟到天数">
                <ItemTemplate>
                  <a href="javascript:void(0);" onclick="show_WA_detail(<%#(int)(((DataRowView)Container.DataItem)["Staff_ID"])%>,2)"><%# GetGridData((int)(((DataRowView)Container.DataItem)["Staff_ID"]),1)%></a>
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn HeaderText="早退天数">
                <ItemTemplate>
                  <a href="javascript:void(0);" onclick="show_WA_detail(<%#(int)(((DataRowView)Container.DataItem)["Staff_ID"])%>,3)"><%# GetGridData((int)(((DataRowView)Container.DataItem)["Staff_ID"]),2)%></a>
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn HeaderText="未考勤天数">
                <ItemTemplate>
                  <a href="javascript:void(0);" onclick="show_WA_detail(<%#(int)(((DataRowView)Container.DataItem)["Staff_ID"])%>,4)"><%# GetGridData((int)(((DataRowView)Container.DataItem)["Staff_ID"]),3)%></a>
                </ItemTemplate>
              </asp:TemplateColumn>
              <asp:TemplateColumn HeaderText="总考勤天数">
                <ItemTemplate>
                  <a href="javascript:void(0);" onclick="show_WA_detail(<%#(int)(((DataRowView)Container.DataItem)["Staff_ID"])%>,5)"><%# GetGridData((int)(((DataRowView)Container.DataItem)["Staff_ID"]),4)%></a>
                </ItemTemplate>
              </asp:TemplateColumn>
            </Columns>
          </asp:DataGrid>
        </td>
      </tr>
    </table>
  </form>
</body>
</html>
